package com.da.javatest.leetCode;

/**
 * @author chenlida
 * @date 2019/3/27 11:42
 * @description
 */
public class Code365 {
    public static void main(String[] args) {
        System.out.println(new Code365().canMeasureWater(2, 6, 3));
    }

    public boolean canMeasureWater(int x, int y, int z) {
        if (z == 0 || x + y == z) {
            return true;
        }
        if (x + y < z) {
            return false;
        }
        if (x > y) {
            int temp = x;
            x = y;
            y = temp;
        }
        if (x == 0) {
            return y == z;
        }
        //寻找最大公约数,辗转相除法
        int val = x;
        while (y % x != 0) {
            val = y % x;
            y = x;
            x = val;
        }
        return z % val == 0;
    }
}
